Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement multi-send transaction command #11738

Merged
merged 22 commits into from
Apr 29, 2022

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Apr 24, 2022

Description

Closes: #7809


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@julienrbrt julienrbrt linked an issue Apr 24, 2022 that may be closed by this pull request
4 tasks
@julienrbrt julienrbrt changed the title feat: implement multi-send transaction cli feat: implement multi-send transaction command Apr 24, 2022
// {4A} / {8A} = {0A}
// {2A} / 0 = panics
// Note, if IsValid was true on Coins, IsValid stays true,
// unless the `divisor` is greater than the smallest coin amount.
Copy link
Member Author

@julienrbrt julienrbrt Apr 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am uncertain if we actually want this behavior, but I created these helpers function for avoiding having to do for every coin:

sendCoins := coins
if split && !coins.IsZero() {
    sendCoins[0].Amount = coins[0].Amount.Quo(totalAddr)
}

If you find this better, then I can modify it and remove the changes in coins.

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

types/coin_test.go Outdated Show resolved Hide resolved
x/bank/client/cli/tx.go Outdated Show resolved Hide resolved
x/bank/client/cli/tx.go Outdated Show resolved Hide resolved
x/bank/types/msgs_test.go Outdated Show resolved Hide resolved
x/bank/client/cli/tx.go Outdated Show resolved Hide resolved
x/bank/client/cli/tx.go Outdated Show resolved Hide resolved
types/coin.go Outdated Show resolved Hide resolved
types/coin.go Outdated Show resolved Hide resolved
types/coin.go Outdated Show resolved Hide resolved
types/coin.go Outdated Show resolved Hide resolved
types/coin.go Show resolved Hide resolved
types/coin.go Outdated Show resolved Hide resolved
types/coin.go Outdated Show resolved Hide resolved
types/coin.go Show resolved Hide resolved
types/coin.go Outdated Show resolved Hide resolved
x/bank/client/cli/tx.go Outdated Show resolved Hide resolved
x/bank/client/cli/tx.go Outdated Show resolved Hide resolved
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! What happens when --split is provided/true, but doesn't have a fully divisible amount? One of the outputs is rounded, correct?

x/bank/client/cli/tx.go Outdated Show resolved Hide resolved
@alexanderbez alexanderbez requested a review from tac0turtle April 25, 2022 21:05
@julienrbrt
Copy link
Member Author

Nice work! What happens when --split is provided/true, but doesn't have a fully divisible amount? One of the outputs is rounded, correct?

Thanks for all the feedback :)

Yes, that's why we need to multiply from sendCoins to get the actual amount: #11738 (comment)

@julienrbrt julienrbrt force-pushed the julien/7809-gaiad-tx-bank-multi-send-cli branch from 26e5d22 to 51ed808 Compare April 25, 2022 22:04
@julienrbrt julienrbrt changed the title feat: implement multi-send transaction command feat: implement multisend transaction command Apr 26, 2022
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@julienrbrt I completely forgot. We need to add a test to x/bank/client/testutil 👍

@julienrbrt julienrbrt changed the title feat: implement multisend transaction command feat: implement multi-send transaction command Apr 26, 2022
types/coin.go Outdated Show resolved Hide resolved
types/coin.go Outdated Show resolved Hide resolved
x/bank/client/cli/tx.go Outdated Show resolved Hide resolved
x/bank/client/cli/tx.go Show resolved Hide resolved
Copy link
Contributor

@likhita-809 likhita-809 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@codecov
Copy link

codecov bot commented Apr 29, 2022

Codecov Report

Merging #11738 (f573ec9) into main (0c0b4da) will increase coverage by 0.07%.
The diff coverage is 98.27%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #11738      +/-   ##
==========================================
+ Coverage   65.94%   66.02%   +0.07%     
==========================================
  Files         669      669              
  Lines       70427    70599     +172     
==========================================
+ Hits        46444    46613     +169     
- Misses      21312    21316       +4     
+ Partials     2671     2670       -1     
Impacted Files Coverage Δ
x/auth/client/cli/tx_multisign.go 0.00% <0.00%> (ø)
types/coin.go 93.56% <100.00%> (+0.44%) ⬆️
x/bank/client/testutil/cli_helpers.go 73.68% <100.00%> (+23.68%) ⬆️
x/bank/client/testutil/suite.go 99.47% <100.00%> (+0.15%) ⬆️
crypto/keys/internal/ecdsa/privkey.go 82.45% <0.00%> (-1.76%) ⬇️
x/group/keeper/keeper.go 53.36% <0.00%> (-0.43%) ⬇️

@julienrbrt julienrbrt merged commit 6a9b824 into main Apr 29, 2022
@julienrbrt julienrbrt deleted the julien/7809-gaiad-tx-bank-multi-send-cli branch April 29, 2022 09:27
@alexanderbez
Copy link
Contributor

@Mergifyio backport release/v0.46.x

mergify bot pushed a commit that referenced this pull request Apr 29, 2022
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Anil Kumar Kammari <anil@vitwit.com>
(cherry picked from commit 6a9b824)

# Conflicts:
#	x/bank/client/cli/tx.go
@mergify
Copy link
Contributor

mergify bot commented Apr 29, 2022

backport release/v0.46.x

✅ Backports have been created

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gaiad tx bank multi-send was not implemented for cli
5 participants